#!/bin/bash
set -e

if [ $# -eq 0 ]; then
	echo "请输入提交消息"
	echo "ps: ./commit.sh 'massge'"
	exit 1
fi

git add .
git commit -m "$(date +%F) $1"

branch=$(git branch --show-current)
if git push origin "$branch"; then
	echo -e "\n\033[32m推送成功\033[0m"
else
	echo -e "\n\033[31m推送失败，请检查网络或权限\033[0m"
	exit 1
fi
